<template>
  <div>
    <h1>{{msg}}</h1>
    <child-component></child-component>
  </div>
</template>

<script>
  import store from './store'
  import childComponent from './child'

  export default {
    data() {
      return {
        msg: 'vuex test'
      }
    },
    store,
    methods: {},
    components: {
      childComponent
    },
    created() {
      let u = navigator.userAgent;
      if (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) {
        this.$store.dispatch('setApp', 'android');
      } else if (!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        this.$store.dispatch('setApp', 'ios');
      } else {
        this.$store.dispatch('setApp', 'PC');
      }
      console.log(this.$store.state.platform);
    },
    mounted() {
      console.log('父组件调用:' + this.$store.getters.doneTodos);  //这个是子组件created 里修改的
    }
  }
</script>

<style scoped>

</style>
